var e = require("../@babel/runtime/helpers/createForOfIteratorHelper");
var t = require("../utils/aes.js"),
  n = require("../utils/wxapp_rsa.js"),
  r = require("../utils/turingSDK.js"),
  a = t.CryptoJS.enc.Utf8.parse("rw9ptc2y3gszxj3d"),
  o = t.CryptoJS.enc.Utf8.parse("dg93rvmqu8nrfu88");
module.exports = {
  showMsg: function (e) {
    wx.showToast({ title: e, icon: "none", duration: 2e3 });
  },
  getTime: function (e) {
    for (
      var t = new Date(),
        n = [],
        r = {},
        a = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六"),
        o = 0;
      o < e;
      o++
    ) {
      t.setDate(t.getDate() + (0 == o ? 0 : 1));
      var c = t.getFullYear(),
        i = t.getMonth() + 1,
        u = t.getDate(),
        s = t.getDay();
      i >= 1 && i <= 9 && (i = "0".concat(i)),
        u >= 1 && u <= 9 && (u = "0".concat(u)),
        (r =
          0 == o
            ? { week: "今天", year: c, date: "".concat(i, "-").concat(u) }
            : 1 == o
              ? { week: "明天", year: c, date: "".concat(i, "-").concat(u) }
              : { week: a[s], year: c, date: "".concat(i, "-").concat(u) }),
        n.push(r);
    }
    return n;
  },
  orderStatus: {
    Unused: "004001",
    used: "004002",
    cancel: "004003",
    Ticketed: "004004",
    Settled: "004005",
    take_ticket: "004006",
    Ticketing: "004007",
    retreat_ticket: "004008",
  },
  payStatus: { pay: "005001", Unpay: "005002" },
  refundStatus: { Unrefund: "002001", examine: "002004", Refunded: "002003" },
  HealthCode: {
    10: { value: "红码", color: "#F43530" },
    "01": { value: "黄码", color: "#DFAB20" },
    "00": { value: "绿码", color: "#00B36F" },
  },
  isMobile: function (e) {
    return /^1[3-9]\d{9}$/.test(e);
  },
  isIdcard: function (e) {
    return /^[\da-z]+$/i.test(e);
  },
  CountDown: function (e) {
    var t = new Date(e).getTime(),
      n = new Date(),
      r = new Date(t + 18e5),
      a = Math.floor(r - n) / 1e3;
    if (a > 1) {
      a -= 1;
      var o = Math.floor(a % 60),
        c = Math.floor((a / 60) % 60);
      return (
        (o = o < 10 ? "0" + o : o),
        "".concat((c = c < 10 ? "0" + c : c), ":").concat(o)
      );
    }
    return 0;
  },
  checkTime: function (e) {
    var t = new Date(),
      n = ""
        .concat(t.getFullYear(), "-")
        .concat(t.getMonth() + 1, "-")
        .concat(t.getDate(), " ")
        .concat(t.getHours(), ":")
        .concat(t.getMinutes(), ":")
        .concat(t.getSeconds()),
      r = ""
        .concat(t.getFullYear(), "-")
        .concat(t.getMonth() + 1, "-")
        .concat(t.getDate(), " ")
        .concat(e, ":00"),
      a = n.replace(/-/g, "/"),
      o = r.replace(/-/g, "/"),
      c = (Date.parse(o) - Date.parse(a)) / 3600 / 1e3;
    return c >= 0 || (!(c < 0) && void 0);
  },
  getAge: function (e) {
    var t = new Date(),
      n = t.getMonth() + 1,
      r = t.getDate(),
      a = t.getFullYear() - e.substring(6, 10) - 1;
    return (
      (e.substring(10, 12) < n ||
        (e.substring(10, 12) == n && e.substring(12, 14) <= r)) &&
        a++,
      a
    );
  },
  isIdcardPrefix: function (t, n) {
    var r,
      a = t.substring(0, 2),
      o = e(n);
    try {
      for (o.s(); !(r = o.n()).done; ) {
        return a == r.value;
      }
    } catch (e) {
      o.e(e);
    } finally {
      o.f();
    }
  },
  throttle: function (e, t) {
    var n = 0,
      r = t || 500;
    return function () {
      var t = this,
        a = new Date();
      a - n > r && (e.call(t, arguments), (n = a));
    };
  },
  isExitOpenId: function (e) {
    var t = requireMiniProgram().getOpenId();
    ("" != t && null != t && null != t) ||
      wx.reLaunch({
        url: "plugin-private://wx393d60d93f70599c/pages/toLogin/index?page=".concat(
          e,
        ),
      });
  },
  encryptBASE64: function (e) {
    var n = t.CryptoJS.enc.Utf8.parse(e);
    return t.CryptoJS.AES.encrypt(n, a, {
      iv: o,
      mode: t.CryptoJS.mode.CBC,
      padding: t.CryptoJS.pad.Pkcs7,
    }).toString();
  },
  decrypt: function (e) {
    var n = t.CryptoJS.AES.decrypt(e, a, {
      iv: o,
      mode: t.CryptoJS.mode.CBC,
      padding: t.CryptoJS.pad.Pkcs7,
    });
    return n.toString(t.CryptoJS.enc.Utf8).toString();
  },
  autograph: function (e) {
    new n.RSAKey();
    var t = n.KEYUTIL.getKey(
      "-----BEGIN PRIVATE KEY-----MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALt2yY6SmshIEFlpbuepE0GQd3K8OrfI+v99PKh/TeCTYXBDZxkFs0vZDlYw2/oFIDDr5Q/SdlUfYoExUzZikfx1P52/bnxFE2b6WBrVRAiKt/Y4Smky5woxoUngoERJw2Ek5vecIFxXncVOFFwOsWtSYgsUCW61EMLWyDVl7ju/AgMBAAECgYBGPCkj+5V2OFm3xiLBNL18MQ4vtIojVW+EzX0ufBPHcjBtiTNVUqdsYXRXopKoR8dZzOfTV7zyA4I6eSp+E8wxr14q2bx+DRmt4kInt0j8ZyFJermyz2BqX/zl95sugAMULoomb4GFrfHjtResDZyG2LwgFXTG1/yZfn2ri88fEQJBAO3eXbud8N2IBZZqy+A2iUxGBsVtdSFxmlm0HlZm3yNV5l8vTYDmo+mknXsjJZgYPghtMbAvIu1Y71hVwcx4pXUCQQDJwNqs2QiVUUFyGx7bhcZOa8G9sEsSh79eaJfxuLdgwU13BL6A0R1L19Ecc7al4neHmw1Lh8K7m954uLOZg9HjAkBSjNFKw01MFGCcCwQmE8ciSUsgSRRVPu+qIfBFW/4kbTM95VSoX2KTOyXMDi6F0iP1GLAdzL36UNr/dQOEynnhAkBoDIz6jafOkixlc7UzU8eVFB/D+1KMSPQZ9Wk/YZs5TBfuZMT23GH2hmQy/z5YSPaKOh3eMTLt3JIcwmzlpEUvAkEApp7GmFQNgMifsz/e+7z0C9fNyQimshH1bQ3pEeFHYuqTjNkw3B7ojAMrnNIlLbo/TOOWgjYR97Sv0Ywo8LAKOA==-----END PRIVATE KEY-----",
    ).signString(e, "sha1");
    return (t = n.hex2b64(t));
  },
  TicketCountDown: function (e) {
    var t = new Date(e).getTime(),
      n = new Date(),
      r = new Date(t + 3e5),
      a = Math.floor(r - n) / 1e3;
    if (a > 1) {
      a -= 1;
      var o = Math.floor(a % 60),
        c = Math.floor((a / 60) % 60);
      return (
        (o = o < 10 ? "0" + o : o),
        "".concat((c = c < 10 ? "0" + c : c), ":").concat(o)
      );
    }
    return 0;
  },
  turingSDKInit: function (e) {
    r.init({ channel: "109002", openid: e }, function (e) {
      r.getDeviceToken(function (e) {
        0 == e.ret && wx.setStorageSync("deviceToken", e.deviceToken);
      });
    });
  },
};
